﻿using System;
using System.Collections.Generic;
using System.Text;
using RAP.Framework.Libary.Utils;

namespace RAP.Framework.Libary.Payment.WxPay
{
  /// <summary>
  /// 订单支付成功后的通知实体
  /// </summary>
  public class PayOrderNotifyData : PayDataBase
  {
    /// <summary>
    /// 业务结果：SUCCESS/FAIL
    /// </summary>
    public virtual string ResultCode { get => this.ToString("result_code"); set => this["result_code"] = value; }

    /// <summary>
    /// 返回状态码：SUCCESS/FAIL 此字段是通信标识，非交易标识，交易是否成功需要查看result_code来判断
    /// </summary>
    public virtual string ReturnCode { get => this.ToString("return_code"); set => this["return_code"] = value; }

    /// <summary>
    /// 返回信息
    /// </summary>
    public virtual string ReturnMsg { get => this.ToString("return_msg"); set => this["return_msg"] = value; }

    /// <summary>
    /// 错误代码
    /// </summary>
    public virtual string ErrCode { get => this.ToString("err_code"); set => this["err_code"] = value; }

    /// <summary>
    /// 错误代码描述
    /// </summary>
    public virtual string ErrMsg { get => this.ToString("err_code_des"); set => this["err_code_des"] = value; }
    
    /// <summary>
    /// 用户在商户appid下的唯一标识
    /// </summary>
    public virtual string OpenId { get => this.ToString("openid"); set => this["openid"] = value; }

    /// <summary>
    /// 用户是否关注公众账号，Y-关注，N-未关注
    /// </summary>
    public virtual string IsSubscribe { get => this.ToString("is_subscribe"); set => this["is_subscribe"] = value; }

    /// <summary>
    /// 银行类型，采用字符串类型的银行标识
    /// </summary>
    public virtual string BankType { get => this.ToString("bank_type"); set => this["bank_type"] = value; }

    /// <summary>
    /// 订单总金额，单位为分
    /// </summary>
    public virtual int TotalFee { get => this.ToInt32("total_fee", 0); set => this["total_fee"] = value; }

    /// <summary>
    /// 应结订单金额=订单金额-非充值代金券金额，应结订单金额<=订单金额
    /// </summary>
    public virtual int SettlementTotalFee { get => this.ToInt32("settlement_total_fee", this.TotalFee); set => this["settlement_total_fee"] = value; }

    /// <summary>
    /// 符合ISO 4217标准的三位字母代码，默认人民币：CNY，其他值列表详见
    /// </summary>
    public virtual string FeeType { get => this.ToString("fee_type"); set => this["fee_type"] = value; }

    /// <summary>
    /// 现金支付金额订单现金支付金额
    /// </summary>
    public virtual int CashFee { get => this.ToInt32("cash_fee"); set => this["cash_fee"] = value; }

    /// <summary>
    /// 货币类型，符合ISO4217标准的三位字母代码，默认人民币：CNY
    /// </summary>
    public virtual string CashFeeType { get => this.ToString("cash_fee_type"); set => this["cash_fee_type"] = value; }

    /// <summary>
    /// 微信支付订单号
    /// </summary>
    public virtual string TransactionId { get => this.ToString("transaction_id"); set => this["transaction_id"] = value; }

    /// <summary>
    /// 商户系统内部订单号，要求32个字符内，只能是数字、大小写字母_-|*且在同一个商户号下唯一
    /// </summary>
    public virtual string TradeNo { get => this.ToString("out_trade_no"); set => this["out_trade_no"] = value; }

    /// <summary>
    /// 附加数据，在查询API和支付通知中原样返回，该字段主要用于商户携带订单的自定义数据
    /// </summary>
    public virtual string Attach { get => this.ToString("attach"); set => this["attach"] = value; }

    /// <summary>
    /// 支付完成时间
    /// </summary>
    public virtual string TimeEnd { get => this.ToString("time_end"); set => this["time_end"] = value; }

    /// <summary>
    /// 交易是否成功
    /// </summary>
    public virtual bool TradeSuccess { get => this.ResultCode == PayAPI.RETURN_SUCCESS; }

  }
}
